#include <iostream>
#include <fstream>

using namespace std;
typedef unsigned long NUM;

int main()
{
	const NUM size = 100;
	NUM **N = new NUM*[size];

	ifstream file ("triangle.txt", ios::in);
	for(NUM a=0; a<size; a++)
	{
		N[a] = new NUM [a+1];
		for(NUM b=0; b<=a; b++)
		{
			file >> N[a][b];
			//cout << N[a][b] << ',';
		}
		//cout << endl;
	}

	for(int a=1; a<size; a++) N[a][0] += N[a-1][0];
	for(int a=1; a<size; a++) N[a][a] += N[a-1][a-1];

	for(int l=2; l<size;l++)
	{
		for(int j=1; j<l;j++)
		{
			NUM a = N[l][j]+N[l-1][j], b = N[l][j]+N[l-1][j-1];
			N[l][j] = (a>b?a:b);
		}
	}

	NUM result = 0, i = 1;
	for(int a=0; a<size; a++)
	{
		if(N[size-1][a] > result) result = N[size-1][a];
	}

	cout << result << endl;
	return 0;
}
